import request from '@/utils/request'

// 获取用户列表数据的接口
// GET /admin/acl/user/{page}/{limit} 
export const reqUserList = (page, limit, username) => {
    return request({
        url: `/admin/acl/user/${page}/${limit}`,
        method: 'get',
        params: {
            username,
        }
    })
}

// 获取新增用户或修改用户接口的函数
export const reqAddOrUpdateUser = (user) => {
    // 修改
    if (user.id) {
        return request({
            url: '/admin/acl/user/update',
            method: 'put',
            data:user
        })
    } else {
        return request({
            url: '/admin/acl/user/save',
            method: 'post',
            data: user
        })
    }
}

// 获取批量删除用户数据的接口
export const reqBatchRemoveUser = (data) => {
    return request({
        url: '/admin/acl/user/batchRemove',
        method: 'post',
        data,
    })
}

// 获取删除用户的接口
export const reqRemoveUser = (id) => {
    return request({
        url: `/admin/acl/user/remove/${id}`,
        method: 'delete'
    })
}

// 获取角色数据的接口
// /admin/acl/user/toAssign/{userId}
export const reqRoleList = (userId) => {
    return request.get(`/admin/acl/user/toAssign/${userId}`)
}

// 获取分配角色数据的接口
// /admin/acl/user/doAssignRole method:post
export const reqUpdateRoles = (data) => {
    return request({
        url: '/admin/acl/user/doAssignRole',
        method: 'post',
        data,
    })
}